#pragma once
#include <iostream>
using std::cin;
using std::cout;
using std::endl;

class Date
{
public:
    Date(int year = 0, int month = 0, int day = 0)
    {
        m_year = year;
        m_month = month;
        m_day = day;
    }

    void Print()
    {
        cout << m_year << "-" << m_month << "-" << m_day << endl;
    }

    bool isLeapYear(int year)
    {
        // 四年一闰百年不闰，四百年一润
        return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
    }

    int getMonthDay(int year, int month)
    {
        const static int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        if (isLeapYear(year) && month == 2)
        {
            return 29;
        }
        return days[month];
    }

    bool operator==(const Date &d) const
    {
        return m_year == d.m_year && m_month == d.m_month && m_day == d.m_day;
    }

    bool operator<(const Date &d) const;

    bool operator>(const Date &d) const
    {
        return !(*this <= d);
    }

    bool operator!=(const Date &d) const
    {
        return !(*this == d);
    }

    bool operator<=(const Date &d) const
    {
        return ((*this < d) || (*this == d));
    }

    bool operator>=(const Date &d) const
    {
        return !(*this < d);
    }

    Date& operator+=(int day);

    Date operator+(int day) const
    {
        Date tmp(*this);
        tmp += day;
        return tmp;
    }

    Date& operator-=(int day);

    Date operator-(int day) const
    {
        Date tmp(*this);
        tmp -= day;
        return tmp;
    }

    int operator-(const Date &d) const;

    Date& operator++()
    {
        *this += 1;
        return *this;
    }

    Date operator++(int)
    {
        Date tmp(*this);
        *this += 1;
        return tmp;
    }

    Date& operator--()
    {
        *this -= 1;
        return *this;
    }

    Date operator--(int)
    {
        Date tmp(*this);
        *this -= 1;
        return tmp;
    }

private:
    int m_year;
    int m_month;
    int m_day;
};